package sort;



/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yuchuang
 * @Date: 2024-01-03 16:20
 * @Description:
 */
public class LinkedList {




    public static class ListNode {
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    }

    /**
     * 尾插法
     */
    public static boolean lastInsert(ListNode head,int data){
        while(head.next!=null){
            head.next= head;
        }
        head.next=new ListNode(data);
        return  true;
    }

    public static boolean lastInsertNode(ListNode head,ListNode node){
        while(head.next!=null){
            head.next= head;
        }
        head.next=node;
        return  true;
    }

}
